<?php
$options->setDefault('button', __('Send'));
$options->setDefault('url', url_for(sfContext::getInstance()->getRouting()->getCurrentInternalUri()));
$options->setDefault('method','post');
$options->setDefault('firstRow', '');
$options->setDefault('lastRow', '');
$options->setDefault('button_ext', '');
$text_size = $options['text_size']
           ? $options['text_size']
           : 27;

$width=  $options['width']?$options['width']:'100%';

use_stylesheet('/sfDoctrinePlugin/css/global.css', 'first');
use_stylesheet('/sfDoctrinePlugin/css/default.css', 'first');
?>

<div id="sf_admin_container" style="width: <?php echo $width ?>">
  <div class="sf_admin_form">
    <form <?php if ($options['id']) echo 'id="'.$options['id'].'"' ?>
      action="<?php echo $options->getRaw('url') ?>"
      method="<?php echo $options['method'] ?>"
      <?php if (!empty($options['isMultipart'])): ?> enctype="multipart/form-data" <?php endif; ?>>

    <?php if ($firstRow = $options->getRaw('firstRow')) echo $firstRow ?>
    <fieldset id="sf_fieldset_none">
      <?php
      $forms = ($options['form'] instanceof sfForm) ? array($options['form']) : $options['form'];

      foreach ( $forms as $form ) {
        use_stylesheets_for_form($form);
        use_javascripts_for_form($form);
        
        if ($form->hasGlobalErrors ()) {
          echo $form->renderGlobalErrors ();
        }
        
        foreach ( $form as $name=>$field ) {
          if ($field->isHidden ())
            continue;
          
          $attributes = array ();
          ?>
          
          <div class="sf_admin_form_row <?php $field->hasError() and print ' errors' ?>">
            <?php echo $field->renderError() ?>
            <div>
              <?php echo $field->renderLabel() ?>

              <div class="content"><?php echo $field->render($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes) ?></div>

              <?php if ($help = $field->renderHelp()): ?>
                <div class="help"><?php echo $help ?></div>
              <?php endif; ?>
            </div>
          </div>
          
          <?php
          }
      }
      ?>
      </fieldset>
      <?php if ($lastRow = $options->getRaw('lastRow')) echo $lastRow ?>

      <?php foreach ($forms as $form) echo $form->renderHiddenFields() ?>

      <?php if ($options['button']!==false): ?>
        <ul class="sf_admin_actions">
          <li>
            <input type="submit" class="input_submit" value="<?php echo $options['button'] ?>" />
          </li>
          <?php if ($extra = $options->getRaw('button_ext')): ?>
            <li class="extra">
              <?php echo $extra ?>
            </li>
          <?php endif ?>
        </ul>
      <?php endif ?>
    </form>
  </div>
</div>
